const util = require('../../../utils/util.js');

Page({
  data: {
    faqList: []
  },

  onLoad() {
    this.loadFaqList();
  },

  loadFaqList() {
    // 模拟常见问题数据
    const faqList = [
      { id: 1, question: '如何预约服务？' },
      { id: 2, question: '如何取消已预约的服务？' },
      { id: 3, question: '忘记登录密码怎么办？' },
      { id: 4, question: '如何修改个人信息？' },
      { id: 5, question: '服务费用如何支付？' }
    ];

    this.setData({
      faqList
    });
  },

  onCallPhone() {
    wx.makePhoneCall({
      phoneNumber: '4001234567'
    }).catch(() => {
      util.showToast('拨号失败');
    });
  },

  onStartChat() {
    util.showToast('正在连接客服...');
    // 实际应跳转到在线客服聊天页面
    // wx.navigateTo({
    //   url: '/pages/chat/chat'
    // });
  },

  onCopyWechat() {
    wx.setClipboardData({
      data: 'zhihuiyanglao888',
      success: () => {
        util.showToast('微信号已复制', 'success');
      }
    });
  },

  onCopyEmail() {
    wx.setClipboardData({
      data: 'service@zhihuiyanglao.com',
      success: () => {
        util.showToast('邮箱地址已复制', 'success');
      }
    });
  },

  onViewAllFaq() {
    wx.navigateTo({
      url: '/pages/mine/customer-service/faq'
    });
  },

  onFaqDetail(e) {
    const id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: `/pages/mine/customer-service/faq-detail?id=${id}`
    });
  },

  onFeedback() {
    wx.navigateTo({
      url: '/pages/mine/customer-service/feedback'
    });
  }
})

